/*
  author Sylvain Bertrand <sylvain.bertrand@gmail.com>
  Protected by linux GNU GPLv2
  Copyright 2012-2014
*/
#include <linux/pci.h>
#include <linux/cdev.h>

#include <alga/rng_mng.h>

#include "mc.h"
#include "rlc.h"
#include "ih.h"
#include "fence.h"
#include "ring.h"
#include "dmas.h"
#include "ba.h"
#include "cps.h"
#include "gpu.h"
#include "drv.h"

#include "regs.h"

static u32 tahiti_golden_rlc_regs[] = {
	0xc424, 0xffffffff, 0x00601005,
	0xc47c, 0xffffffff, 0x10104040,
	0xc488, 0xffffffff, 0x0100000a,
	RLC_LB_CNTR_MAX, 0xffffffff, 0x00000800,
	RLC_LB_CTL, 0xffffffff, 0x800000f4,
	0xf4a8, 0xffffffff, 0x00000000
};

static u32 tahiti_golden_regs_0[] = {
	0x9a10, 0x00010000, 0x00018208,
	0x9830, 0xffffffff, 0x00000000,
	0x9834, 0xf00fffff, 0x00000400,
	0x9838, 0x0002021c, 0x00020200,
	0xc78, 0x00000080, 0x00000000,
	0xd030, 0x000300c0, 0x00800040,
	0xd830, 0x000300c0, 0x00800040,
	0x5bb0, 0x000000f0, 0x00000070,
	0x5bc0, 0x00200000, 0x50100000,
	0x7030, 0x31000311, 0x00000011,
	0x277c, 0x00000003, 0x000007ff,
	0x240c, 0x000007ff, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	PA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x30, 0x000000ff, 0x0040,
	0x34, 0x00000040, 0x00004040,
	SPI_CFG_CTL_0, 0x07ffffff, SCC_ENA_SQG_TOP_EVENTS
							| SCC_EN_SQG_BOP_EVENTS,
	0x8e88, 0x01ff1f3f, 0x00000000,
	0x8e84, 0x01ff1f3f, 0x00000000,
	0x9060, 0x0000007f, 0x00000020,
	TA_CTL_AUX, 0x00010000, 0x00010000,
	0xac14, 0x00000200, 0x000002fb,
	TCP_CHAN_STEER_HI, 0xffffffff, 0x0000543b,
	TCP_CHAN_STEER_LO, 0xffffffff, 0xa9210876,
	0x88d0, 0xffffffff, 0x000fff40,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x15c0, 0x000c0fc0, 0x000c0400
};

static u32 tahiti_golden_regs_1[] = {
	0xc64, 0x00000001, 0x00000001
};

static u32 pitcairn_golden_rlc_regs[] = {
	0xc424, 0xffffffff, 0x00601004,
	0xc47c, 0xffffffff, 0x10102020,
	0xc488, 0xffffffff, 0x01000020,
	RLC_LB_CNTR_MAX, 0xffffffff, 0x00000800,
	RLC_LB_CTL, 0xffffffff, 0x800000a4
};

static u32 pitcairn_golden_regs[] = {
	0x9a10, 0x00010000, 0x00018208,
	0x9830, 0xffffffff, 0x00000000,
	0x9834, 0xf00fffff, 0x00000400,
	0x9838, 0x0002021c, 0x00020200,
	0xc78, 0x00000080, 0x00000000,
	0xd030, 0x000300c0, 0x00800040,
	0xd830, 0x000300c0, 0x00800040,
	0x5bb0, 0x000000f0, 0x00000070,
	0x5bc0, 0x00200000, 0x50100000,
	0x7030, 0x31000311, 0x00000011,
	0x2ae4, 0x00073ffe, 0x000022a2,
	0x240c, 0x000007ff, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	PA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x30, 0x000000ff, 0x0040,
	0x34, 0x00000040, 0x00004040,
	SPI_CFG_CTL_0, 0x07ffffff, SCC_ENA_SQG_TOP_EVENTS
							| SCC_EN_SQG_BOP_EVENTS,
	0x9060, 0x0000007f, 0x00000020,
	TA_CTL_AUX, 0x00010000, 0x00010000,
	0xac14, 0x000003ff, 0x000000f7,
	TCP_CHAN_STEER_HI, 0xffffffff, 0x00000000,
	TCP_CHAN_STEER_LO, 0xffffffff, 0x32761054,
	0x0000, 0x00000000, 0x00000000,
	0x15c0, 0x000c0fc0, 0x000c0400
};

static u32 verde_golden_rlc_regs[] = {
	0xc424, 0xffffffff, 0x033f1005,
	0xc47c, 0xffffffff, 0x10808020,
	0xc488, 0xffffffff, 0x00800008,
	RLC_LB_CNTR_MAX, 0xffffffff, 0x00001000,
	RLC_LB_CTL, 0xffffffff, 0x80010014
};

static u32 verde_golden_regs[] = {
	0x9a10, 0x00010000, 0x00018208,
	0x9830, 0xffffffff, 0x00000000,
	0x9834, 0xf00fffff, 0x00000400,
	0x9838, 0x0002021c, 0x00020200,
	0xc78, 0x00000080, 0x00000000,
	0xd030, 0x000300c0, 0x00800040,
	0xd030, 0x000300c0, 0x00800040,
	0xd830, 0x000300c0, 0x00800040,
	0xd830, 0x000300c0, 0x00800040,
	0x5bb0, 0x000000f0, 0x00000070,
	0x5bc0, 0x00200000, 0x50100000,
	0x7030, 0x31000311, 0x00000011,
	0x2ae4, 0x00073ffe, 0x000022a2,
	0x2ae4, 0x00073ffe, 0x000022a2,
	0x2ae4, 0x00073ffe, 0x000022a2,
	0x240c, 0x000007ff, 0x00000000,
	0x240c, 0x000007ff, 0x00000000,
	0x240c, 0x000007ff, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	PA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x30, 0x000000ff, 0x0040,
	0x34, 0x00000040, 0x00004040,
	SPI_CFG_CTL_0, 0x07ffffff, SCC_ENA_SQG_TOP_EVENTS
							| SCC_EN_SQG_BOP_EVENTS,
	SPI_CFG_CTL_0, 0x07ffffff, SCC_ENA_SQG_TOP_EVENTS
							| SCC_EN_SQG_BOP_EVENTS,
	0x8e88, 0x01ff1f3f, 0x00000000,
	0x8e88, 0x01ff1f3f, 0x00000000,
	0x8e88, 0x01ff1f3f, 0x00000000,
	0x8e84, 0x01ff1f3f, 0x00000000,
	0x8e84, 0x01ff1f3f, 0x00000000,
	0x8e84, 0x01ff1f3f, 0x00000000,
	0x9060, 0x0000007f, 0x00000020,
	TA_CTL_AUX, 0x00010000, 0x00010000,
	0xac14, 0x000003ff, 0x00000003,
	0xac14, 0x000003ff, 0x00000003,
	0xac14, 0x000003ff, 0x00000003,
	TCP_CHAN_STEER_HI, 0xffffffff, 0x00000000,
	TCP_CHAN_STEER_HI, 0xffffffff, 0x00000000,
	TCP_CHAN_STEER_HI, 0xffffffff, 0x00000000,
	TCP_CHAN_STEER_LO, 0xffffffff, 0x00001032,
	TCP_CHAN_STEER_LO, 0xffffffff, 0x00001032,
	TCP_CHAN_STEER_LO, 0xffffffff, 0x00001032,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x15c0, 0x000c0fc0, 0x000c0400
};

static u32 oland_golden_rlc_regs[] = {
	0xc424, 0xffffffff, 0x00601005,
	0xc47c, 0xffffffff, 0x10104040,
	0xc488, 0xffffffff, 0x0100000a,
	RLC_LB_CNTR_MAX, 0xffffffff, 0x00000800,
	RLC_LB_CTL, 0xffffffff, 0x800000f4
};

static u32 oland_golden_regs[] = {
	0x9a10, 0x00010000, 0x00018208,
	0x9830, 0xffffffff, 0x00000000,
	0x9834, 0xf00fffff, 0x00000400,
	0x9838, 0x0002021c, 0x00020200,
	0xc78, 0x00000080, 0x00000000,
	0xd030, 0x000300c0, 0x00800040,
	0xd830, 0x000300c0, 0x00800040,
	0x5bb0, 0x000000f0, 0x00000070,
	0x5bc0, 0x00200000, 0x50100000,
	0x7030, 0x31000311, 0x00000011,
	0x2ae4, 0x00073ffe, 0x000022a2,
	0x240c, 0x000007ff, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	PA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x0000, 0x00000000, 0x00000000,
	0x30, 0x000000ff, 0x0040,
	0x34, 0x00000040, 0x00004040,
	SPI_CFG_CTL_0, 0x07ffffff, SCC_ENA_SQG_TOP_EVENTS
							| SCC_EN_SQG_BOP_EVENTS,
	0x9060, 0x0000007f, 0x00000020,
	TA_CTL_AUX, 0x00010000, 0x00010000,
	0xac14, 0x000003ff, 0x000000f3,
	TCP_CHAN_STEER_HI, 0xffffffff, 0x00000000,
	TCP_CHAN_STEER_LO, 0xffffffff, 0x00003210,
	0x0000, 0x00000000, 0x00000000,
	0x15c0, 0x000c0fc0, 0x000c0400
};

static u32 tahiti_mgcg_cgcg_init[] = {
	0xc400, 0xffffffff, 0xfffffffc,
	GRBM_GFX_IDX, 0xffffffff, GGI_SE_BROADCAST_WRS | GGI_INST_BROADCAST_WRS
							| GGI_SH_BROADCAST_WRS,
	0x9a60, 0xffffffff, 0x00000100,
	0x92a4, 0xffffffff, 0x00000100,
	0xc164, 0xffffffff, 0x00000100,
	0x9774, 0xffffffff, 0x00000100,
	0x8984, 0xffffffff, 0x06000100,
	0x8a18, 0xffffffff, 0x00000100,
	0x92a0, 0xffffffff, 0x00000100,
	0xc380, 0xffffffff, 0x00000100,
	0x8b28, 0xffffffff, 0x00000100,
	0x9144, 0xffffffff, 0x00000100,
	0x8d88, 0xffffffff, 0x00000100,
	0x8d8c, 0xffffffff, 0x00000100,
	0x9030, 0xffffffff, 0x00000100,
	0x9034, 0xffffffff, 0x00000100,
	0x9038, 0xffffffff, 0x00000100,
	0x903c, 0xffffffff, 0x00000100,
	0xad80, 0xffffffff, 0x00000100,
	0xac54, 0xffffffff, 0x00000100,
	0x897c, 0xffffffff, 0x06000100,
	0x9868, 0xffffffff, 0x00000100,
	0x9510, 0xffffffff, 0x00000100,
	0xaf04, 0xffffffff, 0x00000100,
	0xae04, 0xffffffff, 0x00000100,
	0x949c, 0xffffffff, 0x00000100,
	GRBM_GFX_IDX, 0xffffffff, GGI_SE_BROADCAST_WRS | GGI_INST_BROADCAST_WRS
							| GGI_SH_BROADCAST_WRS,
	0x9160, 0xffffffff, 0x00010000,
	0x9164, 0xffffffff, 0x00030002,
	0x9168, 0xffffffff, 0x00040007,
	0x916c, 0xffffffff, 0x00060005,
	0x9170, 0xffffffff, 0x00090008,
	0x9174, 0xffffffff, 0x00020001,
	0x9178, 0xffffffff, 0x00040003,
	0x917c, 0xffffffff, 0x00000007,
	0x9180, 0xffffffff, 0x00060005,
	0x9184, 0xffffffff, 0x00090008,
	0x9188, 0xffffffff, 0x00030002,
	0x918c, 0xffffffff, 0x00050004,
	0x9190, 0xffffffff, 0x00000008,
	0x9194, 0xffffffff, 0x00070006,
	0x9198, 0xffffffff, 0x000a0009,
	0x919c, 0xffffffff, 0x00040003,
	0x91a0, 0xffffffff, 0x00060005,
	0x91a4, 0xffffffff, 0x00000009,
	0x91a8, 0xffffffff, 0x00080007,
	0x91ac, 0xffffffff, 0x000b000a,
	0x91b0, 0xffffffff, 0x00050004,
	0x91b4, 0xffffffff, 0x00070006,
	0x91b8, 0xffffffff, 0x0008000b,
	0x91bc, 0xffffffff, 0x000a0009,
	0x91c0, 0xffffffff, 0x000d000c,
	0x91c4, 0xffffffff, 0x00060005,
	0x91c8, 0xffffffff, 0x00080007,
	0x91cc, 0xffffffff, 0x0000000b,
	0x91d0, 0xffffffff, 0x000a0009,
	0x91d4, 0xffffffff, 0x000d000c,
	0x91d8, 0xffffffff, 0x00070006,
	0x91dc, 0xffffffff, 0x00090008,
	0x91e0, 0xffffffff, 0x0000000c,
	0x91e4, 0xffffffff, 0x000b000a,
	0x91e8, 0xffffffff, 0x000e000d,
	0x91ec, 0xffffffff, 0x00080007,
	0x91f0, 0xffffffff, 0x000a0009,
	0x91f4, 0xffffffff, 0x0000000d,
	0x91f8, 0xffffffff, 0x000c000b,
	0x91fc, 0xffffffff, 0x000f000e,
	0x9200, 0xffffffff, 0x00090008,
	0x9204, 0xffffffff, 0x000b000a,
	0x9208, 0xffffffff, 0x000c000f,
	0x920c, 0xffffffff, 0x000e000d,
	0x9210, 0xffffffff, 0x00110010,
	0x9214, 0xffffffff, 0x000a0009,
	0x9218, 0xffffffff, 0x000c000b,
	0x921c, 0xffffffff, 0x0000000f,
	0x9220, 0xffffffff, 0x000e000d,
	0x9224, 0xffffffff, 0x00110010,
	0x9228, 0xffffffff, 0x000b000a,
	0x922c, 0xffffffff, 0x000d000c,
	0x9230, 0xffffffff, 0x00000010,
	0x9234, 0xffffffff, 0x000f000e,
	0x9238, 0xffffffff, 0x00120011,
	0x923c, 0xffffffff, 0x000c000b,
	0x9240, 0xffffffff, 0x000e000d,
	0x9244, 0xffffffff, 0x00000011,
	0x9248, 0xffffffff, 0x0010000f,
	0x924c, 0xffffffff, 0x00130012,
	0x9250, 0xffffffff, 0x000d000c,
	0x9254, 0xffffffff, 0x000f000e,
	0x9258, 0xffffffff, 0x00100013,
	0x925c, 0xffffffff, 0x00120011,
	0x9260, 0xffffffff, 0x00150014,
	0x9264, 0xffffffff, 0x000e000d,
	0x9268, 0xffffffff, 0x0010000f,
	0x926c, 0xffffffff, 0x00000013,
	0x9270, 0xffffffff, 0x00120011,
	0x9274, 0xffffffff, 0x00150014,
	0x9278, 0xffffffff, 0x000f000e,
	0x927c, 0xffffffff, 0x00110010,
	0x9280, 0xffffffff, 0x00000014,
	0x9284, 0xffffffff, 0x00130012,
	0x9288, 0xffffffff, 0x00160015,
	0x928c, 0xffffffff, 0x0010000f,
	0x9290, 0xffffffff, 0x00120011,
	0x9294, 0xffffffff, 0x00000015,
	0x9298, 0xffffffff, 0x00140013,
	0x929c, 0xffffffff, 0x00170016,
	0x9150, 0xffffffff, 0x96940200,
	0x8708, 0xffffffff, 0x00900100,
	0xc478, 0xffffffff, 0x00000080,
	0xc404, 0xffffffff, 0x0020003f,
	0x30, 0xffffffff, 0x0000001c,
	0x34, 0x000f0000, 0x000f0000,
	0x160c, 0xffffffff, 0x00000100,
	0x1024, 0xffffffff, 0x00000100,
	0x102c, 0x00000101, 0x00000000,
	0x20a8, 0xffffffff, 0x00000104,
	0x264c, 0x000c0000, 0x000c0000,
	0x2648, 0x000c0000, 0x000c0000,
	0x55e4, 0xff000fff, 0x00000100,
	0x55e8, 0x00000001, 0x00000001,
	0x2f50, 0x00000001, 0x00000001,
	0x30cc, 0xc0000fff, 0x00000104,
	0xc1e4, 0x00000001, 0x00000001,
	0xd0c0, 0xfffffff0, 0x00000100,
	0xd8c0, 0xfffffff0, 0x00000100
};

static u32 pitcairn_mgcg_cgcg_init[] = {
	0xc400, 0xffffffff, 0xfffffffc,
	GRBM_GFX_IDX, 0xffffffff, GGI_SE_BROADCAST_WRS | GGI_INST_BROADCAST_WRS
							| GGI_SH_BROADCAST_WRS,
	0x9a60, 0xffffffff, 0x00000100,
	0x92a4, 0xffffffff, 0x00000100,
	0xc164, 0xffffffff, 0x00000100,
	0x9774, 0xffffffff, 0x00000100,
	0x8984, 0xffffffff, 0x06000100,
	0x8a18, 0xffffffff, 0x00000100,
	0x92a0, 0xffffffff, 0x00000100,
	0xc380, 0xffffffff, 0x00000100,
	0x8b28, 0xffffffff, 0x00000100,
	0x9144, 0xffffffff, 0x00000100,
	0x8d88, 0xffffffff, 0x00000100,
	0x8d8c, 0xffffffff, 0x00000100,
	0x9030, 0xffffffff, 0x00000100,
	0x9034, 0xffffffff, 0x00000100,
	0x9038, 0xffffffff, 0x00000100,
	0x903c, 0xffffffff, 0x00000100,
	0xad80, 0xffffffff, 0x00000100,
	0xac54, 0xffffffff, 0x00000100,
	0x897c, 0xffffffff, 0x06000100,
	0x9868, 0xffffffff, 0x00000100,
	0x9510, 0xffffffff, 0x00000100,
	0xaf04, 0xffffffff, 0x00000100,
	0xae04, 0xffffffff, 0x00000100,
	0x949c, 0xffffffff, 0x00000100,
	GRBM_GFX_IDX, 0xffffffff, GGI_SE_BROADCAST_WRS | GGI_INST_BROADCAST_WRS
							| GGI_SH_BROADCAST_WRS,
	0x9160, 0xffffffff, 0x00010000,
	0x9164, 0xffffffff, 0x00030002,
	0x9168, 0xffffffff, 0x00040007,
	0x916c, 0xffffffff, 0x00060005,
	0x9170, 0xffffffff, 0x00090008,
	0x9174, 0xffffffff, 0x00020001,
	0x9178, 0xffffffff, 0x00040003,
	0x917c, 0xffffffff, 0x00000007,
	0x9180, 0xffffffff, 0x00060005,
	0x9184, 0xffffffff, 0x00090008,
	0x9188, 0xffffffff, 0x00030002,
	0x918c, 0xffffffff, 0x00050004,
	0x9190, 0xffffffff, 0x00000008,
	0x9194, 0xffffffff, 0x00070006,
	0x9198, 0xffffffff, 0x000a0009,
	0x919c, 0xffffffff, 0x00040003,
	0x91a0, 0xffffffff, 0x00060005,
	0x91a4, 0xffffffff, 0x00000009,
	0x91a8, 0xffffffff, 0x00080007,
	0x91ac, 0xffffffff, 0x000b000a,
	0x91b0, 0xffffffff, 0x00050004,
	0x91b4, 0xffffffff, 0x00070006,
	0x91b8, 0xffffffff, 0x0008000b,
	0x91bc, 0xffffffff, 0x000a0009,
	0x91c0, 0xffffffff, 0x000d000c,
	0x9200, 0xffffffff, 0x00090008,
	0x9204, 0xffffffff, 0x000b000a,
	0x9208, 0xffffffff, 0x000c000f,
	0x920c, 0xffffffff, 0x000e000d,
	0x9210, 0xffffffff, 0x00110010,
	0x9214, 0xffffffff, 0x000a0009,
	0x9218, 0xffffffff, 0x000c000b,
	0x921c, 0xffffffff, 0x0000000f,
	0x9220, 0xffffffff, 0x000e000d,
	0x9224, 0xffffffff, 0x00110010,
	0x9228, 0xffffffff, 0x000b000a,
	0x922c, 0xffffffff, 0x000d000c,
	0x9230, 0xffffffff, 0x00000010,
	0x9234, 0xffffffff, 0x000f000e,
	0x9238, 0xffffffff, 0x00120011,
	0x923c, 0xffffffff, 0x000c000b,
	0x9240, 0xffffffff, 0x000e000d,
	0x9244, 0xffffffff, 0x00000011,
	0x9248, 0xffffffff, 0x0010000f,
	0x924c, 0xffffffff, 0x00130012,
	0x9250, 0xffffffff, 0x000d000c,
	0x9254, 0xffffffff, 0x000f000e,
	0x9258, 0xffffffff, 0x00100013,
	0x925c, 0xffffffff, 0x00120011,
	0x9260, 0xffffffff, 0x00150014,
	0x9150, 0xffffffff, 0x96940200,
	0x8708, 0xffffffff, 0x00900100,
	0xc478, 0xffffffff, 0x00000080,
	0xc404, 0xffffffff, 0x0020003f,
	0x30, 0xffffffff, 0x0000001c,
	0x34, 0x000f0000, 0x000f0000,
	0x160c, 0xffffffff, 0x00000100,
	0x1024, 0xffffffff, 0x00000100,
	0x102c, 0x00000101, 0x00000000,
	0x20a8, 0xffffffff, 0x00000104,
	0x55e4, 0xff000fff, 0x00000100,
	0x55e8, 0x00000001, 0x00000001,
	0x2f50, 0x00000001, 0x00000001,
	0x30cc, 0xc0000fff, 0x00000104,
	0xc1e4, 0x00000001, 0x00000001,
	0xd0c0, 0xfffffff0, 0x00000100,
	0xd8c0, 0xfffffff0, 0x00000100
};

static u32 verde_mgcg_cgcg_init[] = {
	0xc400, 0xffffffff, 0xfffffffc,
	GRBM_GFX_IDX, 0xffffffff, GGI_SE_BROADCAST_WRS | GGI_INST_BROADCAST_WRS
							| GGI_SH_BROADCAST_WRS,
	0x9a60, 0xffffffff, 0x00000100,
	0x92a4, 0xffffffff, 0x00000100,
	0xc164, 0xffffffff, 0x00000100,
	0x9774, 0xffffffff, 0x00000100,
	0x8984, 0xffffffff, 0x06000100,
	0x8a18, 0xffffffff, 0x00000100,
	0x92a0, 0xffffffff, 0x00000100,
	0xc380, 0xffffffff, 0x00000100,
	0x8b28, 0xffffffff, 0x00000100,
	0x9144, 0xffffffff, 0x00000100,
	0x8d88, 0xffffffff, 0x00000100,
	0x8d8c, 0xffffffff, 0x00000100,
	0x9030, 0xffffffff, 0x00000100,
	0x9034, 0xffffffff, 0x00000100,
	0x9038, 0xffffffff, 0x00000100,
	0x903c, 0xffffffff, 0x00000100,
	0xad80, 0xffffffff, 0x00000100,
	0xac54, 0xffffffff, 0x00000100,
	0x897c, 0xffffffff, 0x06000100,
	0x9868, 0xffffffff, 0x00000100,
	0x9510, 0xffffffff, 0x00000100,
	0xaf04, 0xffffffff, 0x00000100,
	0xae04, 0xffffffff, 0x00000100,
	0x949c, 0xffffffff, 0x00000100,
	GRBM_GFX_IDX, 0xffffffff, GGI_SE_BROADCAST_WRS | GGI_INST_BROADCAST_WRS
							| GGI_SH_BROADCAST_WRS,
	0x9160, 0xffffffff, 0x00010000,
	0x9164, 0xffffffff, 0x00030002,
	0x9168, 0xffffffff, 0x00040007,
	0x916c, 0xffffffff, 0x00060005,
	0x9170, 0xffffffff, 0x00090008,
	0x9174, 0xffffffff, 0x00020001,
	0x9178, 0xffffffff, 0x00040003,
	0x917c, 0xffffffff, 0x00000007,
	0x9180, 0xffffffff, 0x00060005,
	0x9184, 0xffffffff, 0x00090008,
	0x9188, 0xffffffff, 0x00030002,
	0x918c, 0xffffffff, 0x00050004,
	0x9190, 0xffffffff, 0x00000008,
	0x9194, 0xffffffff, 0x00070006,
	0x9198, 0xffffffff, 0x000a0009,
	0x919c, 0xffffffff, 0x00040003,
	0x91a0, 0xffffffff, 0x00060005,
	0x91a4, 0xffffffff, 0x00000009,
	0x91a8, 0xffffffff, 0x00080007,
	0x91ac, 0xffffffff, 0x000b000a,
	0x91b0, 0xffffffff, 0x00050004,
	0x91b4, 0xffffffff, 0x00070006,
	0x91b8, 0xffffffff, 0x0008000b,
	0x91bc, 0xffffffff, 0x000a0009,
	0x91c0, 0xffffffff, 0x000d000c,
	0x9200, 0xffffffff, 0x00090008,
	0x9204, 0xffffffff, 0x000b000a,
	0x9208, 0xffffffff, 0x000c000f,
	0x920c, 0xffffffff, 0x000e000d,
	0x9210, 0xffffffff, 0x00110010,
	0x9214, 0xffffffff, 0x000a0009,
	0x9218, 0xffffffff, 0x000c000b,
	0x921c, 0xffffffff, 0x0000000f,
	0x9220, 0xffffffff, 0x000e000d,
	0x9224, 0xffffffff, 0x00110010,
	0x9228, 0xffffffff, 0x000b000a,
	0x922c, 0xffffffff, 0x000d000c,
	0x9230, 0xffffffff, 0x00000010,
	0x9234, 0xffffffff, 0x000f000e,
	0x9238, 0xffffffff, 0x00120011,
	0x923c, 0xffffffff, 0x000c000b,
	0x9240, 0xffffffff, 0x000e000d,
	0x9244, 0xffffffff, 0x00000011,
	0x9248, 0xffffffff, 0x0010000f,
	0x924c, 0xffffffff, 0x00130012,
	0x9250, 0xffffffff, 0x000d000c,
	0x9254, 0xffffffff, 0x000f000e,
	0x9258, 0xffffffff, 0x00100013,
	0x925c, 0xffffffff, 0x00120011,
	0x9260, 0xffffffff, 0x00150014,
	0x9150, 0xffffffff, 0x96940200,
	0x8708, 0xffffffff, 0x00900100,
	0xc478, 0xffffffff, 0x00000080,
	0xc404, 0xffffffff, 0x0020003f,
	0x30, 0xffffffff, 0x0000001c,
	0x34, 0x000f0000, 0x000f0000,
	0x160c, 0xffffffff, 0x00000100,
	0x1024, 0xffffffff, 0x00000100,
	0x102c, 0x00000101, 0x00000000,
	0x20a8, 0xffffffff, 0x00000104,
	0x264c, 0x000c0000, 0x000c0000,
	0x2648, 0x000c0000, 0x000c0000,
	0x55e4, 0xff000fff, 0x00000100,
	0x55e8, 0x00000001, 0x00000001,
	0x2f50, 0x00000001, 0x00000001,
	0x30cc, 0xc0000fff, 0x00000104,
	0xc1e4, 0x00000001, 0x00000001,
	0xd0c0, 0xfffffff0, 0x00000100,
	0xd8c0, 0xfffffff0, 0x00000100
};

static u32 oland_mgcg_cgcg_init[] =
{
	0xc400, 0xffffffff, 0xfffffffc,
	GRBM_GFX_IDX, 0xffffffff, GGI_SE_BROADCAST_WRS | GGI_INST_BROADCAST_WRS
							| GGI_SH_BROADCAST_WRS,
	0x9a60, 0xffffffff, 0x00000100,
	0x92a4, 0xffffffff, 0x00000100,
	0xc164, 0xffffffff, 0x00000100,
	0x9774, 0xffffffff, 0x00000100,
	0x8984, 0xffffffff, 0x06000100,
	0x8a18, 0xffffffff, 0x00000100,
	0x92a0, 0xffffffff, 0x00000100,
	0xc380, 0xffffffff, 0x00000100,
	0x8b28, 0xffffffff, 0x00000100,
	0x9144, 0xffffffff, 0x00000100,
	0x8d88, 0xffffffff, 0x00000100,
	0x8d8c, 0xffffffff, 0x00000100,
	0x9030, 0xffffffff, 0x00000100,
	0x9034, 0xffffffff, 0x00000100,
	0x9038, 0xffffffff, 0x00000100,
	0x903c, 0xffffffff, 0x00000100,
	0xad80, 0xffffffff, 0x00000100,
	0xac54, 0xffffffff, 0x00000100,
	0x897c, 0xffffffff, 0x06000100,
	0x9868, 0xffffffff, 0x00000100,
	0x9510, 0xffffffff, 0x00000100,
	0xaf04, 0xffffffff, 0x00000100,
	0xae04, 0xffffffff, 0x00000100,
	0x949c, 0xffffffff, 0x00000100,
	GRBM_GFX_IDX, 0xffffffff, GGI_SE_BROADCAST_WRS | GGI_INST_BROADCAST_WRS
							| GGI_SH_BROADCAST_WRS,
	0x9160, 0xffffffff, 0x00010000,
	0x9164, 0xffffffff, 0x00030002,
	0x9168, 0xffffffff, 0x00040007,
	0x916c, 0xffffffff, 0x00060005,
	0x9170, 0xffffffff, 0x00090008,
	0x9174, 0xffffffff, 0x00020001,
	0x9178, 0xffffffff, 0x00040003,
	0x917c, 0xffffffff, 0x00000007,
	0x9180, 0xffffffff, 0x00060005,
	0x9184, 0xffffffff, 0x00090008,
	0x9188, 0xffffffff, 0x00030002,
	0x918c, 0xffffffff, 0x00050004,
	0x9190, 0xffffffff, 0x00000008,
	0x9194, 0xffffffff, 0x00070006,
	0x9198, 0xffffffff, 0x000a0009,
	0x919c, 0xffffffff, 0x00040003,
	0x91a0, 0xffffffff, 0x00060005,
	0x91a4, 0xffffffff, 0x00000009,
	0x91a8, 0xffffffff, 0x00080007,
	0x91ac, 0xffffffff, 0x000b000a,
	0x91b0, 0xffffffff, 0x00050004,
	0x91b4, 0xffffffff, 0x00070006,
	0x91b8, 0xffffffff, 0x0008000b,
	0x91bc, 0xffffffff, 0x000a0009,
	0x91c0, 0xffffffff, 0x000d000c,
	0x91c4, 0xffffffff, 0x00060005,
	0x91c8, 0xffffffff, 0x00080007,
	0x91cc, 0xffffffff, 0x0000000b,
	0x91d0, 0xffffffff, 0x000a0009,
	0x91d4, 0xffffffff, 0x000d000c,
	0x9150, 0xffffffff, 0x96940200,
	0x8708, 0xffffffff, 0x00900100,
	0xc478, 0xffffffff, 0x00000080,
	0xc404, 0xffffffff, 0x0020003f,
	0x30, 0xffffffff, 0x0000001c,
	0x34, 0x000f0000, 0x000f0000,
	0x160c, 0xffffffff, 0x00000100,
	0x1024, 0xffffffff, 0x00000100,
	0x102c, 0x00000101, 0x00000000,
	0x20a8, 0xffffffff, 0x00000104,
	0x264c, 0x000c0000, 0x000c0000,
	0x2648, 0x000c0000, 0x000c0000,
	0x55e4, 0xff000fff, 0x00000100,
	0x55e8, 0x00000001, 0x00000001,
	0x2f50, 0x00000001, 0x00000001,
	0x30cc, 0xc0000fff, 0x00000104,
	0xc1e4, 0x00000001, 0x00000001,
	0xd0c0, 0xfffffff0, 0x00000100,
	0xd8c0, 0xfffffff0, 0x00000100
};

static u32 verde_pg_init[] = {
	0x353c, 0xffffffff, 0x40000,
	0x3538, 0xffffffff, 0x200010ff,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x7007,
	0x3538, 0xffffffff, 0x300010ff,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x400000,
	0x3538, 0xffffffff, 0x100010ff,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x120200,
	0x3538, 0xffffffff, 0x500010ff,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x1e1e16,
	0x3538, 0xffffffff, 0x600010ff,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x171f1e,
	0x3538, 0xffffffff, 0x700010ff,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x353c, 0xffffffff, 0x0,
	0x3538, 0xffffffff, 0x9ff,
	0x3500, 0xffffffff, 0x0,
	0x3504, 0xffffffff, 0x10000800,
	0x3504, 0xffffffff, 0xf,
	0x3504, 0xffffffff, 0xf,
	0x3500, 0xffffffff, 0x4,
	0x3504, 0xffffffff, 0x1000051e,
	0x3504, 0xffffffff, 0xffff,
	0x3504, 0xffffffff, 0xffff,
	0x3500, 0xffffffff, 0x8,
	0x3504, 0xffffffff, 0x80500,
	0x3500, 0xffffffff, 0x12,
	0x3504, 0xffffffff, 0x9050c,
	0x3500, 0xffffffff, 0x1d,
	0x3504, 0xffffffff, 0xb052c,
	0x3500, 0xffffffff, 0x2a,
	0x3504, 0xffffffff, 0x1053e,
	0x3500, 0xffffffff, 0x2d,
	0x3504, 0xffffffff, 0x10546,
	0x3500, 0xffffffff, 0x30,
	0x3504, 0xffffffff, 0xa054e,
	0x3500, 0xffffffff, 0x3c,
	0x3504, 0xffffffff, 0x1055f,
	0x3500, 0xffffffff, 0x3f,
	0x3504, 0xffffffff, 0x10567,
	0x3500, 0xffffffff, 0x42,
	0x3504, 0xffffffff, 0x1056f,
	0x3500, 0xffffffff, 0x45,
	0x3504, 0xffffffff, 0x10572,
	0x3500, 0xffffffff, 0x48,
	0x3504, 0xffffffff, 0x20575,
	0x3500, 0xffffffff, 0x4c,
	0x3504, 0xffffffff, 0x190801,
	0x3500, 0xffffffff, 0x67,
	0x3504, 0xffffffff, 0x1082a,
	0x3500, 0xffffffff, 0x6a,
	0x3504, 0xffffffff, 0x1b082d,
	0x3500, 0xffffffff, 0x87,
	0x3504, 0xffffffff, 0x310851,
	0x3500, 0xffffffff, 0xba,
	0x3504, 0xffffffff, 0x891,
	0x3500, 0xffffffff, 0xbc,
	0x3504, 0xffffffff, 0x893,
	0x3500, 0xffffffff, 0xbe,
	0x3504, 0xffffffff, 0x20895,
	0x3500, 0xffffffff, 0xc2,
	0x3504, 0xffffffff, 0x20899,
	0x3500, 0xffffffff, 0xc6,
	0x3504, 0xffffffff, 0x2089d,
	0x3500, 0xffffffff, 0xca,
	0x3504, 0xffffffff, 0x8a1,
	0x3500, 0xffffffff, 0xcc,
	0x3504, 0xffffffff, 0x8a3,
	0x3500, 0xffffffff, 0xce,
	0x3504, 0xffffffff, 0x308a5,
	0x3500, 0xffffffff, 0xd3,
	0x3504, 0xffffffff, 0x6d08cd,
	0x3500, 0xffffffff, 0x142,
	0x3504, 0xffffffff, 0x2000095a,
	0x3504, 0xffffffff, 0x1,
	0x3500, 0xffffffff, 0x144,
	0x3504, 0xffffffff, 0x301f095b,
	0x3500, 0xffffffff, 0x165,
	0x3504, 0xffffffff, 0xc094d,
	0x3500, 0xffffffff, 0x173,
	0x3504, 0xffffffff, 0xf096d,
	0x3500, 0xffffffff, 0x184,
	0x3504, 0xffffffff, 0x15097f,
	0x3500, 0xffffffff, 0x19b,
	0x3504, 0xffffffff, 0xc0998,
	0x3500, 0xffffffff, 0x1a9,
	0x3504, 0xffffffff, 0x409a7,
	0x3500, 0xffffffff, 0x1af,
	0x3504, 0xffffffff, 0xcdc,
	0x3500, 0xffffffff, 0x1b1,
	0x3504, 0xffffffff, 0x800,
	0x3508, 0xffffffff, 0x6c9b2000,
	0x3510, 0xfc00, 0x2000,
	0x3544, 0xffffffff, 0xfc0,
	0x28d4, 0x00000100, 0x100
};

static void sequence_program(struct pci_dev *dev, u32 *regs, u32 array_sz)
{
	u32 tmp;
	u32 reg;
	u32 and_mask;
	u32 or_mask;
	u16 i;

	if (array_sz % 3)
		return;

	for (i = 0; i < array_sz; i +=3) {
		reg = regs[i + 0];
		and_mask = regs[i + 1];
		or_mask = regs[i + 2];

		if (and_mask == 0xffffffff) {
			tmp = or_mask;
		} else {
			tmp = rr32(dev, reg);
			tmp &= ~and_mask;
			tmp |= or_mask;
		}
		wr32(dev, tmp, reg);
	}
}

static void init(struct pci_dev *dev)
{
	struct dev_drv_data *dd;

	dd = pci_get_drvdata(dev);

	switch (dd->family) {
	case TAHITI:
		tahiti_golden_regs_0[12 * 3] = PA_CL_ENHANCE;
		tahiti_golden_regs_0[12 * 3 + 1] = 0xf000001f;
		tahiti_golden_regs_0[12 * 3 + 2] = PCE_CLIP_VTX_REORDER_ENA
						| set(PCE_CLIP_SEQ_N, 3);

		tahiti_golden_regs_0[13 * 3] = PA_SC_FORCE_EOV_MAX_CNTS;
		tahiti_golden_regs_0[13 * 3 + 1] = 0xffffffff;
		tahiti_golden_regs_0[13 * 3 + 2] =
				set(PSFEMC_FORCE_EOV_MAX_CLK_CNT, 0xffff)
				| set(PSFEMC_FORCE_EOV_MAX_REZ_CNT, 0xff);

		tahiti_golden_regs_0[15 * 3] = PA_SC_MODE_CTL_1;
		tahiti_golden_regs_0[15 * 3 + 1] = 0x07ffffff;
		tahiti_golden_regs_0[15 * 3 + 2] =
					set(PSMC_OUT_OF_ORDER_WATER_MARK, 4)
						| PSMC_OUT_OF_ORDER_PRIM_ENA
						| PSMC_FORCE_EOV_REZ_ENA
						| PSMC_FORCE_EOV_CNTDWN_ENA;

		tahiti_golden_regs_0[16 * 3] = PA_SC_RASTER_CFG;
		tahiti_golden_regs_0[16 * 3 + 1] = 0x3f3f3fff;
		tahiti_golden_regs_0[16 * 3 + 2] =
				  set(PSRC_RB_MAP_PKR_0, PSRC_RB_MAP_2)
				| set(PSRC_RB_MAP_PKR_1, PSRC_RB_MAP_2)
				| set(PSRC_RB_XSEL_2, PSRC_RB_XSEL_2_2)
				| PSRC_RB_XSEL
				| set(PSRC_PKR_MAP, PSRC_PKR_MAP_2)
				| set(PSRC_PKR_XSEL, PSRC_PKR_XSEL_0)
				| set(PSRC_PKR_YSEL, PSRC_PKR_YSEL_1)
				| set(PSRC_SC_MAP, PSRC_SC_MAP_0)
				| set(PSRC_SC_XSEL, PSRC_SC_XSEL_8_WIDE_TILE)
				| set(PSRC_SC_YSEL, PSRC_SC_YSEL_8_WIDE_TILE)
				| set(PSRC_SE_MAP, PSRC_SE_MAP_2)
				| set(PSRC_SE_XSEL, PSRC_SE_XSEL_32_WIDE_TILE)
				| set(PSRC_SE_YSEL, PSRC_SE_YSEL_32_WIDE_TILE);

		tahiti_golden_regs_0[28 * 3] = VGT_GS_VTX_REUSE;
		tahiti_golden_regs_0[28 * 3 + 1] = 0x0000001f;
		tahiti_golden_regs_0[28 * 3 + 2] =
						set(VGVR_VGT_GS_VTX_REUSE, 16);

		tahiti_golden_regs_0[29 * 3] = VM_CTX_0_CTL_0;
		tahiti_golden_regs_0[29 * 3 + 1] = 0x20000000;
		tahiti_golden_regs_0[29 * 3 + 2] = set(VCC_PT_DEPTH, 0)
				| VCC_RANGE_PROTECTION_FAULT_ENA_INT
				| VCC_RNG_PROTECTION_FAULT_ENA_DEFAULT
				| VCC_DUMMY_PAGE_PROTECTION_FAULT_ENA_INT
				| VCC_DUMMY_PAGE_PROTECTION_FAULT_ENA_DEFAULT
				| VCC_PDE0_PROTECTION_FAULT_ENA_INT
				| VCC_PDE0_PROTECTION_FAULT_ENA_DEFAULT
				| BIT(11)
				| VCC_VALID_PROTECTION_FAULT_ENA_INT
				| VCC_VALID_PROTECTION_FAULT_ENA_DEFAULT
				| BIT(14)
				| VCC_RD_PROTECTION_FAULT_ENA_INT
				| VCC_RD_PROTECTION_FAULT_ENA_DEFAULT
				| BIT(17)
				| VCC_WR_PROTECTION_FAULT_ENA_INT
				| VCC_WR_PROTECTION_FAULT_ENA_DEFAULT
				| 0x20f00000;
		break;
	case PITCAIRN:
		pitcairn_golden_regs[12 * 3] = PA_CL_ENHANCE;
		pitcairn_golden_regs[12 * 3 + 1] = 0xf000001f;
		pitcairn_golden_regs[12 * 3 + 2] = PCE_CLIP_VTX_REORDER_ENA
						| set(PCE_CLIP_SEQ_N, 3);

		pitcairn_golden_regs[13 * 3] = PA_SC_FORCE_EOV_MAX_CNTS;
		pitcairn_golden_regs[13 * 3 + 1] = 0xffffffff;
		pitcairn_golden_regs[13 * 3 + 2] =
				set(PSFEMC_FORCE_EOV_MAX_CLK_CNT, 0xffff)
				| set(PSFEMC_FORCE_EOV_MAX_REZ_CNT, 0xff);

		pitcairn_golden_regs[15 * 3] = PA_SC_MODE_CTL_1;
		pitcairn_golden_regs[15 * 3 + 1] = 0x07ffffff;
		pitcairn_golden_regs[15 * 3 + 2] =
					set(PSMC_OUT_OF_ORDER_WATER_MARK, 4)
						| PSMC_OUT_OF_ORDER_PRIM_ENA
						| PSMC_FORCE_EOV_REZ_ENA
						| PSMC_FORCE_EOV_CNTDWN_ENA;

		pitcairn_golden_regs[16 * 3] = PA_SC_RASTER_CFG;
		pitcairn_golden_regs[16 * 3 + 1] = 0x3f3f3fff;
		pitcairn_golden_regs[16 * 3 + 2] =
				  set(PSRC_RB_MAP_PKR_0, PSRC_RB_MAP_2)
				| set(PSRC_RB_MAP_PKR_1, PSRC_RB_MAP_2)
				| set(PSRC_RB_XSEL_2, PSRC_RB_XSEL_2_2)
				| PSRC_RB_XSEL
				| set(PSRC_PKR_MAP, PSRC_PKR_MAP_2)
				| set(PSRC_PKR_XSEL, PSRC_PKR_XSEL_0)
				| set(PSRC_PKR_YSEL, PSRC_PKR_YSEL_1)
				| set(PSRC_SC_MAP, PSRC_SC_MAP_0)
				| set(PSRC_SC_XSEL, PSRC_SC_XSEL_8_WIDE_TILE)
				| set(PSRC_SC_YSEL, PSRC_SC_YSEL_8_WIDE_TILE)
				| set(PSRC_SE_MAP, PSRC_SE_MAP_2)
				| set(PSRC_SE_XSEL, PSRC_SE_XSEL_32_WIDE_TILE)
				| set(PSRC_SE_YSEL, PSRC_SE_YSEL_32_WIDE_TILE);

		pitcairn_golden_regs[25 * 3] = VGT_GS_VTX_REUSE;
		pitcairn_golden_regs[25 * 3 + 1] = 0x0000001f;
		pitcairn_golden_regs[25 * 3 + 2] =
						set(VGVR_VGT_GS_VTX_REUSE, 16);
		break;
	case VERDE:
		verde_golden_regs[18 * 3] = PA_CL_ENHANCE;
		verde_golden_regs[18 * 3 + 1] = 0xf000001f;
		verde_golden_regs[18 * 3 + 2] = PCE_CLIP_VTX_REORDER_ENA
						| set(PCE_CLIP_SEQ_N, 3);
		verde_golden_regs[19 * 3] = PA_CL_ENHANCE;
		verde_golden_regs[19 * 3 + 1] = 0xf000001f;
		verde_golden_regs[19 * 3 + 2] = verde_golden_regs[18 * 3 + 2];
		verde_golden_regs[20 * 3] = PA_CL_ENHANCE;
		verde_golden_regs[20 * 3 + 1] = 0xf000001f;
		verde_golden_regs[20 * 3 + 2] = verde_golden_regs[18 * 3 + 2];

		verde_golden_regs[21 * 3] = PA_SC_FORCE_EOV_MAX_CNTS;
		verde_golden_regs[21 * 3 + 1] = 0xffffffff;
		verde_golden_regs[21 * 3 + 2] =
				set(PSFEMC_FORCE_EOV_MAX_CLK_CNT, 0xffff)
				| set(PSFEMC_FORCE_EOV_MAX_REZ_CNT, 0xff);

		verde_golden_regs[23 * 3] = PA_SC_MODE_CTL_1;
		verde_golden_regs[23 * 3 + 1] = 0x07ffffff;
		verde_golden_regs[23 * 3 + 2] =
					set(PSMC_OUT_OF_ORDER_WATER_MARK, 4)
						| PSMC_OUT_OF_ORDER_PRIM_ENA
						| PSMC_FORCE_EOV_REZ_ENA
						| PSMC_FORCE_EOV_CNTDWN_ENA;

		verde_golden_regs[24 * 3] = PA_SC_RASTER_CFG;
		verde_golden_regs[24 * 3 + 1] = 0x3f3f3fff;
		verde_golden_regs[24 * 3 + 2] =
				  set(PSRC_RB_MAP_PKR_0, PSRC_RB_MAP_2)
				| set(PSRC_RB_MAP_PKR_1, PSRC_RB_MAP_2)
				| set(PSRC_RB_XSEL_2, PSRC_RB_XSEL_2_0)
				| PSRC_RB_XSEL
				| set(PSRC_PKR_MAP, PSRC_PKR_MAP_2)
				| set(PSRC_PKR_XSEL, PSRC_PKR_XSEL_0)
				| set(PSRC_PKR_YSEL, PSRC_PKR_YSEL_1)
				| set(PSRC_SC_MAP, PSRC_SC_MAP_0)
				| set(PSRC_SC_XSEL, PSRC_SC_XSEL_8_WIDE_TILE)
				| set(PSRC_SC_YSEL, PSRC_SC_YSEL_8_WIDE_TILE)
				| set(PSRC_SE_MAP, PSRC_SE_MAP_0)
				| set(PSRC_SE_XSEL,PSRC_SE_XSEL_8_WIDE_TILE)
				| set(PSRC_SE_YSEL, PSRC_SE_YSEL_8_WIDE_TILE);
		verde_golden_regs[25 * 3] = PA_SC_RASTER_CFG;
		verde_golden_regs[25 * 3 + 1] = 0x3f3f3fff;
		verde_golden_regs[25 * 3 + 2] = verde_golden_regs[24 * 3 + 2];
		verde_golden_regs[26 * 3] = PA_SC_RASTER_CFG;
		verde_golden_regs[26 * 3 + 1] = 0x3f3f3fff;
		verde_golden_regs[26 * 3 + 2] = verde_golden_regs[24 * 3 + 2];

		verde_golden_regs[48 * 3] = VGT_GS_VTX_REUSE;
		verde_golden_regs[48 * 3 + 1] = 0x0000001f;
		verde_golden_regs[48 * 3 + 2] = set(VGVR_VGT_GS_VTX_REUSE, 16);
		verde_golden_regs[49 * 3] = VGT_GS_VTX_REUSE;
		verde_golden_regs[49 * 3 + 1] = 0x0000001f;
		verde_golden_regs[49 * 3 + 2] = set(VGVR_VGT_GS_VTX_REUSE, 16);
		verde_golden_regs[50 * 3] = VGT_GS_VTX_REUSE;
		verde_golden_regs[50 * 3 + 1] = 0x0000001f;
		verde_golden_regs[50 * 3 + 2] = set(VGVR_VGT_GS_VTX_REUSE, 16);
		break;
	case OLAND:
		oland_golden_regs[12 * 3] = PA_CL_ENHANCE;
		oland_golden_regs[12 * 3 + 1] = 0xf000001f;
		oland_golden_regs[12 * 3 + 2] = PCE_CLIP_VTX_REORDER_ENA
						| set(PCE_CLIP_SEQ_N, 3);

		oland_golden_regs[13 * 3] = PA_SC_FORCE_EOV_MAX_CNTS;
		oland_golden_regs[13 * 3 + 1] = 0xffffffff;
		oland_golden_regs[13 * 3 + 2] =
				set(PSFEMC_FORCE_EOV_MAX_CLK_CNT, 0xffff)
				| set(PSFEMC_FORCE_EOV_MAX_REZ_CNT, 0xff);

		oland_golden_regs[15 * 3] = PA_SC_MODE_CTL_1;
		oland_golden_regs[15 * 3 + 1] = 0x07ffffff;
		oland_golden_regs[15 * 3 + 2] =
					set(PSMC_OUT_OF_ORDER_WATER_MARK, 4)
						| PSMC_OUT_OF_ORDER_PRIM_ENA
						| PSMC_FORCE_EOV_REZ_ENA
						| PSMC_FORCE_EOV_CNTDWN_ENA;

		oland_golden_regs[16 * 3] = PA_SC_RASTER_CFG;
		oland_golden_regs[16 * 3 + 1] = 0x3f3f3fff;
		oland_golden_regs[16 * 3 + 2] =
				  set(PSRC_RB_MAP_PKR_0, PSRC_RB_MAP_2)
				| set(PSRC_RB_MAP_PKR_1, PSRC_RB_MAP_0)
				| set(PSRC_RB_XSEL_2, PSRC_RB_XSEL_2_0)
				| PSRC_RB_YSEL
				| set(PSRC_PKR_MAP, PSRC_PKR_MAP_2)
				| set(PSRC_PKR_XSEL, PSRC_PKR_XSEL_0)
				| set(PSRC_PKR_YSEL, PSRC_PKR_YSEL_0)
				| set(PSRC_SC_MAP, PSRC_SC_MAP_0)
				| set(PSRC_SC_XSEL, PSRC_SC_XSEL_8_WIDE_TILE)
				| set(PSRC_SC_YSEL, PSRC_SC_YSEL_8_WIDE_TILE)
				| set(PSRC_SE_MAP, PSRC_SE_MAP_0)
				| set(PSRC_SE_XSEL,PSRC_SE_XSEL_8_WIDE_TILE)
				| set(PSRC_SE_YSEL, PSRC_SE_YSEL_8_WIDE_TILE);

		oland_golden_regs[25 * 3] = VGT_GS_VTX_REUSE;
		oland_golden_regs[25 * 3 + 1] = 0x0000001f;
		oland_golden_regs[25 * 3 + 2] = set(VGVR_VGT_GS_VTX_REUSE, 16);
		break;
	default:
		/* XXX: HAINAN ? */
		break;
	}
}

static void program(struct pci_dev *dev)
{
	struct dev_drv_data *dd;

	dd = pci_get_drvdata(dev);

	switch (dd->family) {
	case TAHITI:
		sequence_program(dev, tahiti_golden_regs_0,
					ARRAY_SIZE(tahiti_golden_regs_0));
		sequence_program(dev, tahiti_golden_rlc_regs,
					ARRAY_SIZE(tahiti_golden_rlc_regs));
		sequence_program(dev, tahiti_mgcg_cgcg_init,
					ARRAY_SIZE(tahiti_mgcg_cgcg_init));
		sequence_program(dev, tahiti_golden_regs_1,
					ARRAY_SIZE(tahiti_golden_regs_1));
		break;
	case PITCAIRN:
		sequence_program(dev, pitcairn_golden_regs,
					ARRAY_SIZE(pitcairn_golden_regs));
		sequence_program(dev, pitcairn_golden_rlc_regs,
					ARRAY_SIZE(pitcairn_golden_rlc_regs));
		sequence_program(dev, pitcairn_mgcg_cgcg_init,
					ARRAY_SIZE(pitcairn_mgcg_cgcg_init));
		break;
	case VERDE:
		sequence_program(dev, verde_golden_regs,
						ARRAY_SIZE(verde_golden_regs));
		sequence_program(dev, verde_golden_rlc_regs,
					ARRAY_SIZE(verde_golden_rlc_regs));
		sequence_program(dev, verde_mgcg_cgcg_init,
					ARRAY_SIZE(verde_mgcg_cgcg_init));
		sequence_program(dev, verde_pg_init,
						ARRAY_SIZE(verde_pg_init));
		break;
	case OLAND:
		sequence_program(dev, oland_golden_regs,
						ARRAY_SIZE(oland_golden_regs));
		sequence_program(dev, oland_golden_rlc_regs,
					ARRAY_SIZE(oland_golden_rlc_regs));
		sequence_program(dev, oland_mgcg_cgcg_init,
					ARRAY_SIZE(oland_mgcg_cgcg_init));
		break;
	default:
		/* XXX: HAINAN ? */
		break;
	}
}

void golden_regs(struct pci_dev *dev)
{
	init(dev);
	program(dev);
}
